﻿using System;
using System.Text;

namespace EmptyWallGallery.FrontEnd.template
{
    public partial class Default : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindArtists();
        }

        public void BindArtists()
        {
            var isSelected = false;
            var strOut = new StringBuilder();
            var strItem = new StringBuilder();
            var albumItem = Core.BLL.Album.Instance.GetAll();
            var strSelected = "";

            foreach (var albumListView in albumItem)
            {
                if (Page.RouteData.Values["AlbumId"] != null)
                {
                    if (Convert.ToInt32(Page.RouteData.Values["AlbumId"]) == albumListView.AlbumId)
                    {
                        strSelected = " class=\"selected\"";
                        isSelected = true;
                    }
                    else
                    {
                        strSelected = "";
                    }
                }
                else
                {
                    strSelected = "";
                }

                strItem.Append("<li>");
                strItem.Append("     <a" + strSelected + " href='/artists/" + albumListView.AlbumId + "_" +
                              Core.Utilities.Common.Instance.Utf8ToAscii(albumListView.AlbumName) + "' title='" + albumListView.AlbumName + "'>" +
                              albumListView.AlbumName + "</a>");
                strItem.Append("</li>");                
            }

            if (!isSelected)
            {
                strSelected = " class=\"selected\"";
            }
            strOut.Append("<ul><li><a" + strSelected + " href=\"/artists\">ARTISTS</a></li>");
            strOut.Append(strItem);
            strOut.Append("</ul>");
            left.InnerHtml = strOut.ToString();
        }

        protected string WriteAlbum(string albumId, string albumName)
        {
            var strOut = new StringBuilder();

            return strOut.ToString();
        }
    }
}